function ajax(options) {
    const defaultOptions = {
        method: "get",
        url: "/"
    }

    const opt = {
        ...defaultOptions,
        ...options
    }

    console.log(opt);
}


ajax(
    {
        method: "get",
        url: "/",
        token: "123456"
    }
)

//调用：什么都不传递,不报错
ajax()

//方式：利用参数的默认值
function ajax1(
    {
        method = "get",
        url = "/"
    } = {}
) {
    console.log(method, url);
}

ajax1()
